class ObjectHelper {
	
	//
	// merge two objects, one from the user
	// and is JSON, the other is the default
	// values this object should have
	//
	public static function merge( o:Dynamic, defaults:Dynamic ):Dynamic {
		var default_props : Array<String> = Reflect.fields(defaults);
		var value : Dynamic;
		for ( prop in default_props ) {
			if (!Reflect.hasField(o, prop))
			{
				value = Reflect.field(defaults,prop);
				Reflect.setField(o, prop, value);
			}
		}
		return o;
	}
	
	public static function merge_2( json:Dynamic, defaults:Dynamic ):Void {
		var json_props : Array<String> = Reflect.fields(json);
		var json_prop_value : Dynamic;
		for ( prop in json_props ) {
			json_prop_value = Reflect.field(json, prop);
			Reflect.setField(defaults, prop, json_prop_value);
		}
	}
}
